package com.ass.rocketmq.admin;

import com.ass.rocketmq.constant.ProducerGroupName;
import org.apache.rocketmq.acl.common.AclClientRPCHook;
import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DefaultMqAdmin {


    @Value("${spring.profiles.active}")
    private String active;

    @Value("${rocketmq.accessKey}")
    private String accessKey;

    @Value("${rocketmq.secretKey}")
    private String secretKey;

    @Value("${rocketmq.namespace}")
    private String namespace;


    @Value("${rocketmq.name-server}")
    private String namesrvAddr;

    @Bean
    public DefaultMQAdminExt defaultMQAdminExt(){
        DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(
                new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)));
        defaultMQAdminExt.setNamespace(namespace);
        defaultMQAdminExt.setNamesrvAddr(namesrvAddr);
        defaultMQAdminExt.setAdminExtGroup(ProducerGroupName.DEFAULT_ADMIN_GROUP_NAME.name());
        return defaultMQAdminExt;
    }



}
